//
//  ST_Tian270AttachmentModel.swift
//  btvideo
//
//  Created by mac on 2021/1/18.
//  Copyright © 2021 JarvanZhang. All rights reserved.
//

import UIKit
import SwiftyJSON


enum ST_TIANRecordType:Int {
    /**
     取消通话
     */
    case cancel = 0
    /**
     对方取消 拒绝
     */
    case refuse = 1
    /**
     正常聊天
     */
    case normalChat = 2
    /**
     对方忙线
     */
    case busy = 3
}

/**
 通话记录
 */
class ST_Tian270AttachmentModel: ST_BTMessageAttachDecoder {
    
    
    
    var type: ST_TIANRecordType = .cancel
    
    /**
     1 语音 ， 2 视频
     */
    var agoraType:Int = 1
    
    var time:Float = 0
    
    // 用于展示
    lazy var labelStr:String = {
        switch type {
        case .normalChat:
            
            let date = seconds_to_hours_minutes_seconds(seconds: time.int)
            
            let hours = date.hour
            
            let minutes = date.minute
            
            let seconds = date.second
            
            if hours > 0{
                return String(format: "%02d:%02d:%02d", hours,minutes,seconds)
            }else{
                return  String(format: "%02d:%02d", minutes,seconds)
            }
            
        case .busy:
            
            return "忙线中"
            
        case .refuse:
            
            return "已拒绝"
            
        default:
            
            return "已取消"
        }
    }()
    
    override func encode() -> String {
        
        let dict = ["type":type.rawValue,"time":time,"agoraType":agoraType,"msgType":270] as [String : Any]
        
        let json = JSON(dict)
        
        let res = json.rawString() ?? ""
        
        return res
    }
    
}
